package dd.prog2.exercises.set02.sequenses;

public abstract class Filter extends Sequence {
	protected Sequence s;
	protected int next;
	protected boolean hasNext = true;

	abstract boolean testPassCondition(int element);

	public int nextElement() {
		return next;
	}

	public boolean hasNext() {
		computeNext();
		return hasNext;
	}

	void computeNext() {
		do {
			if (s.hasNext() == false) {
				hasNext = false;
				break;
			}
			next = s.nextElement();

		} while (!testPassCondition(next));
	}
}
